-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Orientation fix for mobile #38
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
==========================================
- Coverage 100% 99.12% -0.88%
==========================================
Files 10 10
Lines 108 114 +6
Branches 19 22 +3
==========================================
+ Hits 108 113 +5
- Partials 0 1 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for helping with the project. I added some comments that need to be solved before merging the pull request. Please, don't forget to add yourself to the contributor's list and so fix the tests to recover the coverage.
if (isMobileDevice()) { | ||
return isLandscape() ? "landscape-primary" : "portrait"; | ||
} else { | ||
return window.screen.orientation.type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should replace window.screen.orientation
with something else since it's not fully supported yet by all browsers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, will look into this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this? https://polyfill.io/v2/docs/features/#screen_orientation
@@ -1,16 +1,29 @@ | |||
import React, { Component } from "react"; | |||
import PropTypes from "prop-types"; | |||
|
|||
const isMobileDevice = () => | |||
typeof window.orientation !== "undefined" || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid that window.orientation
is not going to be our best friend since it's deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow I wasn't aware of this, I'll look for an alternative approach 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should re-think the solution because the device orientation stuff is kind of experimental. Basically, the idea behind the feature is to prevent the game to be rendered in small screens. We can simply do that based on the screen width and use the resize event to swap components as we currently do with the Orientation
component. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 makes sense, I can make those changes. Do you have a minimum width in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's show the Game
component at minimum 542px width. Below we can just show the RotateInfo
component. Please, remember to listen to the resize event and also perform the check on mounting phase. Test your code and include yourself into the contributor's list :) Thanks again for the collaboration!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any advance on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yo, I had a lot going on at work 😅 I'm almost done, will definitely push this week.
Description
Game didn't work on mobile devices, this is one way to fix it. Feedback is welcome :)
Fixes #37
Checklist: